import json


# 递归删除字典中指定key的代码
def delete_key_recursive(data, key_to_delete):
    """
    递归删除字典中指定key的值。
    Args:
        data: 字典或嵌套字典。
        key_to_delete: 要删除的key。
    """
    if key_to_delete in data:
        del data[key_to_delete]
    if isinstance(data, dict):
        for k, v in data.items():
            if isinstance(v, (dict, list)):
                delete_key_recursive(v, key_to_delete)
    elif isinstance(data, list):
        for item in data:
            if isinstance(item, (dict, list)):
                delete_key_recursive(item, key_to_delete)


json_data = """
{
    "name": "John",
    "age": {"address":true,"bbb":111},
    "address": {
        "city": "New York",
        "state": "NY",
        "country": "USA"
    }
}
"""
data = json.loads(json_data)
delete_key_recursive(data, "address")
json_result = json.dumps(data)
print("json_result")
print(json_result)
